package com.mingtu.guards.adapter;

import android.content.Context;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mingtu.common.base.BaseApplication;
import com.mingtu.hikvideo2.utils.CalendarUtil;
import com.mingtu.guards.R;
import com.mingtu.guards.bean.MonitoringRecCarBean;

public class MonitoringRecAdapter3 extends BaseQuickAdapter<MonitoringRecCarBean.PageBean.ListBean, BaseViewHolder> {
    private Context context;
    public MonitoringRecAdapter3(Context context) {
        super(R.layout.item_monitoring_rec2);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MonitoringRecCarBean.PageBean.ListBean listBean) {
        String imgUrl = listBean.getCarPicUri();
        String cameraName = listBean.getMonitoringName();
        String eventTime = listBean.getCrossTime();

        String plateNo = listBean.getPlateNo();
        String vehicleType = listBean.getVehicleType();


        long time = CalendarUtil.yyyy_MM_dd_T_HH_mm_SSSZToLong(eventTime);
        String myTime = TimeUtils.millis2String(time);


        if (!StringUtils.isEmpty(imgUrl)) {
            Glide.with(context)
                    .load(imgUrl)
                    .apply(BaseApplication.getRequestOptions())
                    .into((ImageView) helper.getView(R.id.iv_img));
        } else {
            helper.getView(R.id.iv_img).setBackgroundResource(R.mipmap.img_default_news);
        }

        if (!StringUtils.isEmpty(cameraName)) {
            helper.setText(R.id.tv_monitoring_name,cameraName);
        } else {
            helper.setText(R.id.tv_monitoring_name,"");
        }

        if (!StringUtils.isEmpty(myTime)) {
            helper.setText(R.id.tv_time,myTime);
        } else {
            helper.setText(R.id.tv_time,"");
        }

        helper.setText(R.id.tv_result,plateNo + "  " + vehicleType);
    }
}
